<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>练习2</title>
    <script>
        let arr = [1, 1, 1, 2, 3, 56, 2, 5, 5, 6, 8, 7, 8, 12];
        let newArr = [];
        let n = 0;
        //去重
        for (let i = 0; i < arr.length; i++) {
            if (!check(newArr, arr[i])) {
                newArr[n++] = arr[i];
            }
        }
        console.log(newArr)
        function check(a, v) {
            let flag = false;
            for (let i = 0; i < a.length; i++) {
                if (a[i] === v) {
                    flag = true;
                    break;
                }
            }
            return flag;
        }
        //
    </script>
</head>

<body>

</body>

</html>